package com.luckynote.common.base.dubbo;

import org.apache.dubbo.rpc.*;
import org.slf4j.MDC;

/**
 * <pre>
 * *********************************************
 * Copyright LUCKY-NOTE.
 * All rights reserved.
 * ****************************************************
 *  Version       Date         Author            Desc
 *    v1.0       2019/7/7      bingo            日志隐式传参设置值
 * ****************************************************
 * </pre>
 */
public class LogTransferFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        invocation.getAttachments().put(LogEnum.TRACE_ID.getCode(), MDC.get(LogEnum.TRACE_ID.getCode()));
        invocation.getAttachments().put(LogEnum.MODULE_NAME.getCode(), MDC.get(LogEnum.MODULE_NAME.getCode()));
        return invoker.invoke(invocation);
    }
}
